Cypher textΒΆ

import sys

# Map the uppercase letters forwards
_MAPPING = {
    'Q': 'P',
    'W': 'O',
    'E': 'I',
    'R': 'U',
    'T': 'Y',

    'A': 'L',
    'S': 'K',
    'D': 'J',
    'F': 'H',
    # 'G': 'G',

    'Z': 'M',
    'X': 'N',
    'C': 'B',
    # 'V': 'V',
}

# Map the lowercase letters forwards:
_MAPPING.update({key.lower(): value.lower() for key, value in _MAPPING.items()})

# Map both the uppercase and lowercase letters backwards:
_MAPPING.update({value: key for key, value in _MAPPING.items()})

def encrypt(plaintext):
    cyphertext = ''.join(_MAPPING.get(c, c) for c in plaintext)
    return cyphertext

def main():
    plaintext = sys.argv[-1]
    cyphertext = encrypt(plaintext)
    print(cyphertext)

if __name__ == '__main__':
    main()